package com.jf.springmvc.exception;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-11-05
 * Time:17:48
 */
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler({ArrayIndexOutOfBoundsException.class, AgeException.class})
    public String exceptionHandler(Exception ex, HttpServletRequest request) {
        request.setAttribute("message", ex.getMessage());
        return "exception";
    }
}
